package com.liuchong.cloudquotationtwo.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

/**
 * @author: liuchong
 * @create: 2023/2/27 18:08
 * @description:
 */
@RestController
public class QuotationController {
    @RequestMapping(value = "quotation", method = RequestMethod.GET)
    public String getQuotation(@RequestParam(value = "data") String data) throws IOException {
//        File file = new File("/Users/liuchong/learning-notes/PracticalMicroservives/cloud/cloud-quotation-two/src/main/java/com/liuchong/cloudquotationtwo/controller/quotation_data.txt");
//        BufferedWriter bw = new BufferedWriter(new FileWriter(file, true));
//        try {
//            bw.write(data + System.currentTimeMillis());
//            bw.newLine();
//            bw.flush();
//        } catch (Exception e) {
//            e.printStackTrace();
//        } finally {
//            try {
//                if (bw != null)
//                    bw.close();
//            } catch (Exception e) {
//                e.printStackTrace();
//            }
//        }
        return data + "Two";
    }
}
